package top.lishuoboy.docker2.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class DockerController {
    @GetMapping("/")
    public Object index() {
        log.warn("index");
        return "首页";
    }

    @Value("${my.name:李四}")
    String myMame = "张三";

    @GetMapping("/testEnv")
    public Object testEnv() {
        log.warn("myMame=={}", myMame);
        return myMame;
    }

    @Autowired
    StringRedisTemplate redisTemplate;

    @GetMapping("/testNetwork")
    Object testNetwork() {
        String now = DateUtil.now();
        log.warn(now);
        redisTemplate.opsForValue().set("lishuoboy-docker2", now);
        return MapUtil.builder("时间", redisTemplate.opsForValue().get("lishuoboy-docker2")).build();
    }
}
